import request from '@/utils/request'
import apis from '@/api/index'

export function getPatentBusiness (parameter) {
  return request({
    url: apis.PatentBusiness,
    method: 'get',
    params: parameter
  })
}

export function postPatentBusiness (data) {
  return request({
    url: apis.PatentBusiness,
    method: 'post',
    data: data
  })
}

export function getDesignBusiness (parameter) {
  return request({
    url: apis.DesignBusiness,
    method: 'get',
    params: parameter
  })
}

export function getTradeBusiness (parameter) {
  return request({
    url: apis.TradeBusiness,
    method: 'get',
    params: parameter
  })
}

export function getEditBusiness (id) {
  return request({
    url: `${apis.EditBusiness}?business_id=${id}`,
    method: 'get'
  })
}

export function getEditDesign (id) {
  return request({
    url: `${apis.EditDesign}?business_id=${id}`,
    method: 'get'
  })
}

export function postEditBusiness (id, data) {
  return request({
    url: `${apis.EditBusiness}?business_id=${id}`,
    method: 'post',
    data: data
  })
}

export function postDesignBusiness (id, data) {
  return request({
    url: `${apis.EditDesign}?business_id=${id}`,
    method: 'post',
    data: data
  })
}

export function getMatList (parameter) {
  return request({
    url: apis.GetMat,
    method: 'get',
    params: parameter
  })
}

export function getStateList (parameter) {
  return request({
    url: apis.GetState,
    method: 'get',
    params: parameter
  })
}

export function delState (id) {
  return request({
    url: `${apis.DelState}?state_id=${id}`,
    method: 'get'
  })
}

export function delMat (id) {
  return request({
    url: `${apis.DelMat}?mat_id=${id}`,
    method: 'get'
  })
}

export function getEditMat (parameter) {
  return request({
    url: apis.EditMat,
    method: 'get',
    params: parameter
  })
}

export function postEditMat (bid, mid, data) {
  return request({
    url: `${apis.EditMat}?business_id=${bid}&mat_id=${mid}`,
    method: 'post',
    data: data
  })
}

export function getEditState (parameter) {
  return request({
    url: apis.EditState,
    method: 'get',
    params: parameter
  })
}

export function postEditState (bid, mid, data) {
  return request({
    url: `${apis.EditState}?business_id=${bid}&state_id=${mid}`,
    method: 'post',
    data: data
  })
}

export function getAdd () {
  return request({
    url: apis.AddBusiness,
    method: 'get'
  })
}

export function getCategory (cat) {
  return request({
    url: `${apis.AddBusiness}?category=${cat}`,
    method: 'get'
  })
}

export function postAdd (data) {
  return request({
    url: apis.AddBusiness,
    method: 'post',
    data: data
  })
}

export function getExtList (parameter, id) {
  return request({
    url: `${apis.ExtList}?filter[business_id]=${id}`,
    method: 'get',
    params: parameter
  })
}

export function getAddExt (id) {
  return request({
    url: `${apis.AddExt}?business_id=${id}`,
    method: 'get'
  })
}

export function postAddExt (id, data) {
  return request({
    url: `${apis.AddExt}?business_id=${id}`,
    method: 'post',
    data: data
  })
}

export function getEditExt (bid, eid) {
  return request({
    url: `${apis.EditExt}?business_id=${bid}&ext_id=${eid}`,
    method: 'get'
  })
}

export function postEditExt (bid, eid, data) {
  return request({
    url: `${apis.EditExt}?business_id=${bid}&ext_id=${eid}`,
    method: 'post',
    data: data
  })
}

export function delExt (id) {
  return request({
    url: `${apis.DelExt}?ext_id=${id}`,
    method: 'get'
  })
}

export function getAddState (id) {
  return request({
    url: `${apis.EditState2}?business_id=${id}`,
    method: 'get'
  })
}

export function postAddState (id, data) {
  return request({
    url: `${apis.EditState2}?business_id=${id}`,
    method: 'post',
    data: data
  })
}

export function getSaveState () {
  return request({
    url: apis.GetEditState,
    method: 'get'
  })
}

export function postSaveState (data) {
  return request({
    url: apis.GetEditState,
    method: 'post',
    data: data
  })
}

export function delBusiness (id) {
  return request({
    url: `${apis.DelBusiness}?business_id=${id}`,
    method: 'get'
  })
}
